//package com.bookcity.front.webfront.security;
//
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.authentication.AuthenticationServiceException;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
//import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * @author oldliu
// * @since 1.0
// */
//public class DouyinFilter extends AbstractAuthenticationProcessingFilter {
//    private static final AntPathRequestMatcher DEFAULT_ANT_PATH_REQUEST_MATCHER = new AntPathRequestMatcher("/member/login", "POST");
//    private boolean postOnly = true;
//    public DouyinFilter(){
//        super(DEFAULT_ANT_PATH_REQUEST_MATCHER);
//    }
//    public DouyinFilter(AuthenticationManager authenticationManager){
//        super(DEFAULT_ANT_PATH_REQUEST_MATCHER,authenticationManager);
//    }
//    @Override
//    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
//        if (postOnly && !request.getMethod().equals("POST")) {
//            throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
//        }
//
//        String douyinid = obtainMobileid(request);
//
//
//        DouyinToken authRequest = new DouyinToken(douyinid,"douyinuser");
//
//        setDetails(request, authRequest);
//
//        return this.getAuthenticationManager().authenticate(authRequest);
//
//    }
//    protected void setDetails(HttpServletRequest request, DouyinToken authRequest) {
//        authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request));
//    }
//    private String obtainMobileid(HttpServletRequest request) {
//        return request.getHeader("token");
//    }
//}
